/*  RESET
------------------------------------------------------------------------------------------------------ */

@import "partials/library/reset";



/*  GRAPPELLI IMPORTS
------------------------------------------------------------------------------------------------------ */

@import "partials/skins/grp-default";

@import "partials/library/spritesheet";
@import "partials/library/mixins";
@import "partials/library/borders";
@import "partials/library/margins-paddings";
@import "partials/library/sprites";

@import "partials/typography/base";



/*  RTL STYLES
------------------------------------------------------------------------------------------------------ */

body.rtl {
    font-size: $grp-font-size;
    line-height: $grp-line-height;

    #grp-user-tools>li {
        list-style-image: none;
        list-style-type: none;
        margin-left: 0;
        white-space: nowrap;
        float: left;
        padding-left: 0;
        padding-right: 0;
        border-left: 1px solid #343434;
        border-right: 1px solid #090909;
    }

    // HEADER
    header#grp-header {
        #grp-navigation {
            #grp-admin-title {
                padding: 10px 0 10px 10px;
            }

            ul#grp-user-tools {
                margin: 0 0 0 -10px;
                border-right: 1px solid #343434;
                border-left: 0 !important;

                >li {
                    float: right;

                    &:last-child {
                        border-right: 1px solid #090909;
                        border-left: 0;
                    }

                    &.grp-user-options-container:last-child {
                        margin-right: 0;
                        margin-left: 11px;
                    }
                }
            }

            ul li.grp-collapse.grp-open>ul {
                position: absolute;
                z-index: 1010;
                display: block;
                margin: -1px -1px 0 0;
                width: 202px;

                li {
                    border-right: 0 !important
                }
            }
        }
    }

    #grp-page-tools {
        float: left;
        right: 0;
        margin-left: -10px;

        li {
            float: right;

            &:first-child {
                padding-right: 5px;
                padding-left: 0;
            }

            &:last-child {
                padding-left: 5px;
                padding-right: 0;
            }
        }
    }

    #grp-breadcrumbs {
        float: right;

        >ul {
            @include horizontal-list(5px, right);
            @include grp-padding($grp-padding-size-s 20px);

            a {
                padding-right: 0;
                padding-left: 15px;
                @include grp-icon-sprite($breadcrumbs-rtl);
            }
        }
    }


    // SUBMIT-ROW
    .grp-submit-row>ul>li,
    .grp-submit-row>div>div {
        float: left;
        margin-left: 0;
        margin-right: 10px;

        &.grp-float-left {
            float: right !important;
            margin-left: 10px;
            margin-right: 0;
        }
    }

    &.grp-login .grp-module.grp-submit-row ul li,
    &.grp-login .grp-module.grp-submit-row>div>div {
        float: left;
    }

    // OBJECT TOOLS
    .grp-object-tools {
        float: left;

        li {
            float: right;
            padding-right: 5px;
            padding-left: 5px;

            &:first-child {
                padding-right: 0;
            }

            &:last-child {
                padding-left: 0;
            }

            a {
                &.grp-add-link {
                    padding-right: 28px;
                    padding-left: 15px;
                    @include grp-background-gradient-icon-combo($object-tools-add-link, #999, #888,
                        $offset-x: 95%);

                    &:hover {
                        @include grp-background-gradient-icon-combo($object-tools-add-link, #36b0d9, #309bbf,
                            $offset-x: 95%);
                    }
                }

                &.grp-viewsite-link,
                &[target="_blank"] {
                    padding-right: 28px;
                    padding-left: 15px;
                    @include grp-background-gradient-icon-combo($object-tools-viewsite-link, #999, #888,
                        $offset-x: 95%);

                    &:hover {
                        @include grp-background-gradient-icon-combo($object-tools-viewsite-link, #36b0d9, #309bbf,
                            $offset-x: 95%);
                    }
                }
            }
        }
    }

    // TOOLS
    .grp-tools {
        float: left;
        padding-left: 5px;

        li {
            float: right;
            padding-right: 1px;
            padding-left: 1px;

            &:first-child {
                padding-right: 0;
            }

            &:last-child {
                padding-left: 0;
            }
        }

        a.grp-edit-link {
            transform: rotate(180deg);
        }
    }

    .grp-tools-container .grp-tools {
        right: 0;
        // margin-left: -20px;
    }

    .grp-module .grp-row>.grp-tools {
        right: 0;
        margin-left: -9px;
    }

    .grp-group>h2+.grp-tools {
        right: 0;
        margin-left: 1px;
    }

    input.grp-has-related-lookup,
    input.vDateField.hasDatepicker,
    input.vTimeField.hasTimepicker,
    input.vFileBrowseField {
        padding-left: 24px !important;
        padding-right: 5px !important;
    }

    // BUTTONS
    input[type="button"],
    button,
    a.fb_show,
    a.related-lookup,
    body.tinyMCE input[name="src"]+div a,
    body.tinyMCE input[name="href"]+div a {
        margin-left: 0;
        margin-right: -25px;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        border-top-left-radius: $grp-form-field-border-radius;
        border-bottom-left-radius: $grp-form-field-border-radius;
    }

    // DATE/TIME
    p.datetime {
        white-space: nowrap;
        position: relative;
        display: inline-block;

        input.vTimeField {
            margin-left: 0;
            margin-right: 6px;
        }
    }

    // READONLY
    div.grp-readonly {
        &+div.grp-readonly {
            margin-left: 0;
            margin-right: 20px;
        }
    }

    // RELATED LOOKUP
    a.related-lookup+strong {
        margin-left: 0;
        margin-right: 5px;
    }

    .grp-placeholder-related-fk,
    .grp-placeholder-related-m2m,
    .grp-placeholder-related-generic {
        margin-left: 0;
        margin-right: 130px;

        .grp-separator {
            &:after {
                padding-left: 4px;
                padding-right: 0;
            }
        }
    }

    // ADD ANOTHER
    a.add-another {
        margin-left: 0;
        margin-right: 7px;
    }

    .grp-td a.add-another {
        float: left;
        margin-left: -10px;
        margin-right: 7px;
    }

    .grp-td .grp-related-widget-tools a.add-another {
        float: none;
        margin-left: auto;
        margin-right: auto;
    }

    .radiolist.inline+a.add-another,
    .checkboxlist.inline+a.add-another {
        float: none;
        margin-left: -10px;
        margin-right: 0;
    }

    // ACTIONS
    .grp-actions {
        @include horizontal-list(5px, right);
        float: left;

        li {

            &.grp-add-link,
            &.grp-change-link,
            &.grp-delete-link {

                a,
                >span:first-child {
                    padding-right: $grp-padding-size-l;
                    padding-left: 0;
                }
            }

            &.grp-add-link a {
                @include grp-icon-sprite($add-link-small,
                    $offset-x: 50%);

                &:hover {
                    @include grp-icon-sprite($add-link-small-hover,
                        $offset-x: 50%);
                }
            }

            &.grp-change-link a {
                @include grp-icon-sprite($change-link-small,
                    $offset-x: 50%);

                &:hover {
                    @include grp-icon-sprite($change-link-small-hover,
                        $offset-x: 50%);
                }
            }

            &.grp-delete-link a,
            &.grp-delete-link>span:first-child {
                @include grp-icon-sprite($delete-link-small,
                    $offset-x: 50%);
            }

            &.grp-icon {

                a,
                >span:first-child {
                    padding: 0 6px 0 6px;
                }
            }
        }
    }

    .grp-changelist-actions {
        >button {
            margin-right: 0;
        }
    }

    // LISTING
    .grp-listing,
    .grp-listing-small {
        li {

            &.grp-add-link,
            &.grp-change-link,
            &.grp-delete-link {
                padding-right: $grp-padding-size-l + 5;
                padding-left: 0;

                a,
                >span:first-child {
                    margin-right: - $grp-margin-size-m - 5;
                    margin-left: 0;
                    padding-right: $grp-padding-size-m + 5;
                    padding-left: 0;
                }
            }

            &.grp-add-link a {
                @include grp-icon-sprite($add-link-small,
                    $offset-x: 104%);

                &:hover {
                    @include grp-icon-sprite($add-link-small-hover,
                        $offset-x: 104%);
                }
            }

            &.grp-change-link a {
                @include grp-icon-sprite($change-link-small,
                    $offset-x: 104%);

                &:hover {
                    @include grp-icon-sprite($change-link-small-hover,
                        $offset-x: 104%);
                }
            }

            &.grp-delete-link a,
            &.grp-delete-link>span:first-child {
                @include grp-icon-sprite($delete-link-small,
                    $offset-x: 100%);
            }
        }
    }

    // MODULES, ROWS, CELLS
    .grp-module {
        .grp-row:not(tr) {
            float: right;

            &.grp-cells {
                .grp-cell {
                    display: table-cell;
                    vertical-align: top;
                    position: relative;
                    padding: 8px 0 8px 20px;
                    border-left: 1px solid #fff;
                    border-right: 0;

                    &+.grp-cell {
                        padding-left: 20px;
                        padding-right: 0;
                        border-right: 1px solid #ddd;
                        border-left: 0;
                    }

                    &:last-of-type {
                        padding-left: 0;
                        padding-right: 20px;
                        border-left: 0 !important;
                        border-right: 1px solid #ddd !important;
                    }

                }
            }
        }
    }

    // TABULAR
    .grp-tabular {
        .grp-table {

            .grp-th,
            .grp-td {
                margin-right: 0;
                border-left: 1px solid #fff;
                border-right: 1px solid #e0e0e0;

                &:first-of-type {
                    padding-left: 20px;
                    padding-right: 10px;
                }

                &:last-child {
                    padding-left: 10px;
                }
            }

            .grp-thead {

                .grp-th,
                .grp-td {
                    background: none;
                    border-top: 0;
                    // &:last-of-type {
                    //  border-right: 0;
                    // }
                }
            }

            .grp-tbody {

                .grp-th,
                .grp-td {
                    border-bottom: 1px solid #d4d4d4;
                    border-top: 1px solid #d4d4d4;

                    &:last-of-type {
                        border-left: 1px solid #d4d4d4;
                    }

                    &:last-child {
                        border-top-right-radius: $grp-border-radius - 1px;
                        border-bottom-right-radius: $grp-border-radius - 1px;
                        border-top-left-radius: 0;
                        border-bottom-left-radius: 0;
                    }

                    &:first-of-type {
                        border-left: 1px solid #fff;
                        border-right: 1px solid #d4d4d4;
                        border-top-right-radius: $grp-border-radius - 1px;
                        border-bottom-right-radius: $grp-border-radius - 1px;
                        border-top-left-radius: 0;
                        border-bottom-left-radius: 0;

                        ;
                    }

                    &.grp-tools-container {
                        padding-left: 0;
                        border-top-right-radius: 0;
                        border-bottom-right-radius: 0;
                        border-top-left-radius: $grp-border-radius - 1px;
                        border-bottom-left-radius: $grp-border-radius - 1px;
                    }
                }
            }

            .grp-tfoot {
                .grp-td {
                    &:last-of-type {
                        border-right: 0;
                    }
                }
            }
        }
    }

    // TABLES
    table.grp-table {
        thead {
            th {
                border-right: 1px solid $grp-table-border-color;
                border-left: 0;

                &:first-child {
                    border-right: 0;
                }

                &:first-of-type {
                    border-top-right-radius: $grp-border-radius - 1px;
                    border-top-left-radius: 0;
                }

                &:last-of-type {
                    border-top-left-radius: $grp-border-radius - 1px;
                    border-top-right-radius: 0;
                }
            }
        }

        tbody {
            tr {

                td,
                th {
                    border-right: 1px solid #e4e4e4;

                    &:first-child {
                        border-right: 0 !important;
                    }
                }

                &.grp-row-even td,
                &.grp-row-even th,
                &.grp-row-odd td,
                &.grp-row-odd th {
                    border-left: 0;
                    border-right: 1px solid #e0e0e0;
                }

                &:last-child {

                    td,
                    th {
                        &:first-child {
                            border-bottom-right-radius: $grp-border-radius - 1px;
                            border-bottom-left-radius: 0;
                        }

                        &:last-child {
                            border-bottom-left-radius: $grp-border-radius - 1px;
                            border-bottom-right-radius: 0;
                        }
                    }
                }
            }
        }

        tfoot {
            td {
                &:first-child {
                    border-right: 0;
                }
            }
        }

        td,
        th {

            a.fb_show,
            a.related-lookup {
                margin: -5px -25px -11px 0;
            }
        }
    }

    table.grp-table.grp-sortable {
        thead {
            th {
                &.sortable {
                    // .grp-text {
                    //     float: right;
                    // }

                    .grp-sortoptions {
                        float: left;
                        clear: left;
                        margin: 0 0 0 5px;

                        a {
                            float: left;
                        }

                        span.grp-sortpriority {
                            float: left;
                        }
                    }

                    &.sorted {
                        .grp-text a {
                            padding-right: 10px;
                            padding-left: 60px;
                        }
                    }
                }
            }
        }
    }

    // PAGINATION
    .grp-pagination ul {
        float: right;

        li {
            float: right;
            margin-left: 1px;
            margin-right: 0;

            &.grp-results {
                margin-left: 4px;
                margin-right: 0;
            }

            &:last-child {
                clear: left;
            }
        }
    }

    // DATE HIERARCHY
    .grp-date-hierarchy ul {
        float: right;

        li {
            float: right;

            a.grp-date-hierarchy-back {
                padding-right: 15px;
                padding-left: 5px;
                @include grp-icon-sprite($date-hierarchy-back-rtl, $offset-x: 100%);
            }
        }
    }

    // SEARCH
    input[type="text"].grp-search-field {
        margin-left: -5px;
        margin-right: 0;
        padding-left: 30px;
        padding-right: 10px;
    }

    // FILTER
    .grp-pulldown-container {
        .grp-pulldown-handler {
            @include grp-icon-sprite($pulldown-handler);
        }

        &.grp-pulldown-state-open {
            .grp-pulldown-handler {
                @include grp-icon-sprite($pulldown-handler-selected);
                background-color: #e1f0f5;
            }
        }
    }

    .grp-filter {
        .grp-row {
            &.grp-selected {
                a {
                    padding-right: 17px;
                    padding-left: 10px;
                    color: $grp-font-color;
                    @include grp-icon-sprite($filter-choice-selected-small,
                        $offset-x: 100%);
                }
            }
        }

        @include legacy-pie-clearfix;
    }

    // CHANGELIST-ACTIONS
    li.grp-changelist-actions {
        select {
            float: right;
            margin: 1px 0 0 5px;
        }

        li {
            margin-left: 4px;
            margin-right: 0;
            float: right !important;

            &:first-child {
                padding-right: 0;
            }

            &:last-child {
                padding-left: 0;
            }
        }
    }

    // FORMS
    .grp-row input[type="checkbox"]+label,
    .grp-row input[type="radio"]+label {
        margin: 0 5px 0 0;
    }

    select {
        padding: 4px 2px 4px 3px;
        // -moz-appearance: none; // not implemented in -moz yet, see https://bugzilla.mozilla.org/show_bug.cgi?id=649849
    }

    @media screen and (-webkit-min-device-pixel-ratio:0) {

        select,
        select:focus {
            padding: 4px 5px 4px 28px;
            appearance: none;
            background-image: url('../images/icons/form-select.png');
            background-position: 0 50%;
            background-repeat: no-repeat;
        }

        select[multiple] {
            background-image: none;
        }
    }

    .radiolist.inline,
    ul.checkboxlist.inline {
        float: right;
        padding-left: 20px;
        padding-right: 0;

        li {
            float: right;
            padding-left: 20px;
            padding-right: 0;
        }
    }

    .grp-module.grp-tbody .radiolist.inline li,
    .grp-module.grp-tbody .radiolist.inline>div,
    .grp-module.grp-tbody ul.checkboxlist.inline li {
        float: right;
        padding-left: 20px;
        padding-right: 0;
    }

    // AUTOCOMPLETES
    .grp-autocomplete-wrapper-m2m,
    .grp-autocomplete-wrapper-fk {

        a.grp-related-remove,
        div.grp-loader {
            display: inline-block;
            position: absolute;
            left: 24px !important;
            right: auto;
        }

        div.grp-loader {
            background: #fdfdfd url('../images/backgrounds/loading-small.gif') 50% 50% no-repeat scroll;
        }

        a.related-lookup {
            left: 0;
            right: auto;
        }
    }

    .grp-autocomplete-wrapper-m2m {
        ul.grp-repr {
            float: right;
            padding-left: 55px;
            padding-right: 5px;

            li {
                float: right;

                &.grp-repr {
                    margin: 3px 1px 0 5px;

                    a.grp-m2m-remove {
                        padding-right: 5px;
                        padding-left: 0;
                    }
                }
            }
        }

        a.related-lookup {
            left: -1px !important;
        }

        a.grp-related-remove+a.grp-related-lookup {
            border-bottom-left-radius: 3px;
            border-bottom-right-radius: 0;
        }

        a.grp-related-remove,
        a.grp-related-remove+div.grp-loader {
            left: 23px !important;
            right: auto;
        }
    }

    .grp-autocomplete-wrapper-fk {
        input.ui-autocomplete-input {
            padding-left: 55px;
            padding-right: 5px;
        }
    }

    td .grp-autocomplete-wrapper-m2m a.related-lookup,
    td .grp-autocomplete-wrapper-fk a.related-lookup {
        margin-top: 0 !important;
    }

    // SELECTORS
    .selector {
        float: right;

        .selector-available,
        .selector-chosen {
            float: right;

            h2 {
                padding: 7px 7px 6px 5px;
            }
        }

        ul.selector-chooser {
            float: right;
        }

        .selector-filter {
            padding: 3px 2px 2px 5px;
            background-position: 10px 50%;

            input[type="text"] {
                float: right;
                margin-right: 3px;
            }
        }

        select[multiple] {
            margin: 0 -1px 0 0;
            padding-right: 3px;
            padding-left: 0;
        }

        &.stacked {
            ul.selector-chooser {
                margin: 4px 356px 0 0;

                li {
                    float: right;
                }
            }
        }

        a.selector-add {
            background-image: url('../images/icons/selector-remove-m2m-horizontal.png');

            &:hover {
                background-image: url('../images/icons/selector-remove-m2m-horizontal_hover.png');
            }
        }

        a.selector-remove {
            background-image: url('../images/icons/selector-add-m2m-horizontal.png');

            &:hover {
                background-image: url('../images/icons/selector-add-m2m-horizontal_hover.png');
            }
        }
    }

    .grp-related-widget-wrapper {
        float: right;
    }

    .grp-related-widget-tools {
        position: absolute;
        right: auto;
        left: -30px;

        a.grp-change-related {
            transform: rotate(180deg);
        }
    }

    .grp-related-widget-wrapper+p.grp-help {
        clear: right;
    }

    .grp-table img.grp-help-tooltip {
        position: absolute;
        left: 18px;
        right: auto;
        top: 3px;
    }

    // JQUERY UI
    .ui-datepicker {
        table {
            th {
                text-align: center;
            }

            th,
            td {
                border: 0;
            }
        }
    }

    // TYPOGRAPHY
    caption,
    th,
    td {
        text-align: right;
    }

    a {
        &.grp-back-link {
            @include grp-icon-sprite($back-link-rtl, $offset-x: 100%);

            &:hover {
                @include grp-icon-sprite($back-link-rtl_hover, $offset-x: 100%);
            }

            &.grp-icon-text {
                padding-left: 0;
                padding-right: 24px;
            }
        }

        &.grp-link-external {
            padding-left: 0;
            padding-right: 18px;
            @include grp-icon-sprite($link-external-rtl-small,
                $offset-x: 107%);

            &:hover {
                @include grp-icon-sprite($link-external-rtl-small-hover,
                    $offset-x: 107%);
            }
        }

        &.grp-link-internal {
            padding-left: 0;
            padding-right: 18px;
            @include grp-icon-sprite($link-internal-rtl-small,
                $offset-x: 115%);

            &:hover {
                @include grp-icon-sprite($link-internal-rtl-small-hover,
                    $offset-x: 115%);
            }
        }
    }

    .grp-float-left {
        float: right !important;
    }

    .grp-float-right {
        float: left !important;
    }

    // FILEBROWSER
    &.grp-filebrowser table td ul.grp-actions {
        right: -5px;
        left: 0;
        margin: 0 0 -1px -5px;
    }
}